﻿using System;
using System.Net;
using System.Net.NetworkInformation;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace Metal_Archives
{
    public class CommonMethods
    {
        public bool isOnline()
        {
            if (NetworkInterface.GetIsNetworkAvailable())
            {
                return true;
            }
            else
            {
                noInt();
                return false;
            }
        }

        public bool isOnlineE(DownloadStringCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                return true;
            }
            else
            {
                noInt();
                return false;
            }
        }

        public void noInt()
        {
            MessageBox.Show("No active internet connection found.");
        }

        public bool isThemedark()
        {
            bool darkTheme = false;

            Color themeColor = (Color)Application.Current.Resources["PhoneForegroundColor"];

            if (themeColor.ToString() == "#FFFFFFFF")
            {
                darkTheme = true;
            }
            else if (themeColor.ToString() == "#DE000000")
            {
                darkTheme = false;
            }

            return darkTheme;
        }

        public string themeFontColor()
        {
            string color = "";

            Color themeColor = (Color)Application.Current.Resources["PhoneForegroundColor"];

            if (themeColor.ToString() == "#FFFFFFFF")
            {
                color = "White";
            }
            else if (themeColor.ToString() == "#DE000000")
            {
                color = "Black";
            }

            return color;
        }
    }
}
